package com.kevinwu.sqlSession;

import java.beans.IntrospectionException;
import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import java.util.List;

public interface SqlSession {

    /**
     * 查询所有记录
     * @param statementId
     * @param params
     * @param <E>
     * @return
     * @throws IllegalAccessException
     * @throws IntrospectionException
     * @throws InstantiationException
     * @throws NoSuchFieldException
     * @throws SQLException
     * @throws InvocationTargetException
     * @throws ClassNotFoundException
     */
    public <E> List<E> selectAll(String statementId, Object... params) throws IllegalAccessException, IntrospectionException, InstantiationException, NoSuchFieldException, SQLException, InvocationTargetException, ClassNotFoundException;

    /**
     * 查询一条记录
     * @param statementId
     * @param params
     * @param <T>
     * @return
     * @throws IllegalAccessException
     * @throws ClassNotFoundException
     * @throws IntrospectionException
     * @throws InstantiationException
     * @throws SQLException
     * @throws InvocationTargetException
     * @throws NoSuchFieldException
     */
    public <T> T selectOne(String statementId, Object... params) throws IllegalAccessException, ClassNotFoundException, IntrospectionException, InstantiationException, SQLException, InvocationTargetException, NoSuchFieldException;

    /**
     * 获取接口Mapper对象
     * @param mapperClass
     * @param <T>
     * @return
     */
    public <T> T getMapper(Class<?> mapperClass);

    /**
     * 新增记录
     * @param object
     */
    public void insert(String statementId, Object... object) throws ClassNotFoundException, SQLException, IllegalAccessException, NoSuchFieldException;

    /**
     * 更新记录
     * @param object
     */
    public void update(String statementId, Object... object) throws ClassNotFoundException, SQLException, IllegalAccessException, NoSuchFieldException;

    /**
     * 删除记录
     * @param object
     */
    public void delete(String statementId, Object... object) throws ClassNotFoundException, SQLException, IllegalAccessException, NoSuchFieldException;
}
